﻿using System;
using FirebirdSql.Data.FirebirdClient;
using Csla;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Data;

namespace RMSM
{
    [Serializable()]
    public class BDDoanhThuBO : Csla.BusinessBase<BDDoanhThuBO>
    {
        #region Business Properties
        private int _Thang = 0;
        public int Thang
        {
            get { return this._Thang; }
            set { this._Thang = value; }
        }

        private double _TongGiaTriHD = 0;
        public double TongGiaTriHD
        {
            get { return this._TongGiaTriHD; }
            set { this._TongGiaTriHD = value; }
        }

        //tổng số tiền đã nhận của hợp đồng
        private double _TongTienDaTra = 0;
        public double TongTienDaTra
        {
            get { return this._TongTienDaTra; }
            set { this._TongTienDaTra = value; }
        }

        private double _TongTienThucNhan = 0;
        public double TongTienThucNhan
        {
            get { return this._TongTienThucNhan; }
            set { this._TongTienThucNhan = value; }
        }


        private double _TongTienTPTD = 0;
        public double TongTienTPTD
        {
            get { return this._TongTienTPTD; }
            set { this._TongTienTPTD = value; }
        }

        private double _TongTienDaTraTPTD = 0;
        public double TongTienDaTraTPTD
        {
            get { return this._TongTienDaTraTPTD; }
            set { this._TongTienDaTraTPTD = value; }
        }

        private double _TongTienTPTDThucNhan = 0;
        public double TongTienTPTDThucNhan
        {
            get { return this._TongTienTPTDThucNhan; }
            set { this._TongTienTPTDThucNhan = value; }
        }


        private double _TongTienChupHinh = 0;
        public double TongTienChupHinh
        {
            get { return this._TongTienChupHinh; }
            set { this._TongTienChupHinh = value; }
        }

        private double _TongTienDaTraChupHinh = 0;
        public double TongTienDaTraChupHinh
        {
            get { return this._TongTienDaTraChupHinh; }
            set { this._TongTienDaTraChupHinh = value; }
        }

        private double _TongTienChupHinhThucNhan = 0;
        public double TongTienChupHinhThucNhan
        {
            get { return this._TongTienChupHinhThucNhan; }
            set { this._TongTienChupHinhThucNhan = value; }
        }


        private double _TongTienQuayPhim = 0;
        public double TongTienQuayPhim
        {
            get { return this._TongTienQuayPhim; }
            set { this._TongTienQuayPhim = value; }
        }

        private double _TongTienDaTraQuayPhim = 0;
        public double TongTienDaTraQuayPhim
        {
            get { return this._TongTienDaTraQuayPhim; }
            set { this._TongTienDaTraQuayPhim = value; }
        }

        private double _TongTienQuayPhimThucNhan = 0;
        public double TongTienQuayPhimThucNhan
        {
            get { return this._TongTienQuayPhimThucNhan; }
            set { this._TongTienQuayPhimThucNhan = value; }
        }


        private double _TongTienDVK = 0;
        public double TongTienDVK
        {
            get { return this._TongTienDVK; }
            set { this._TongTienDVK = value; }
        }

        private double _TongTienDaTraDVK = 0;
        public double TongTienDaTraDVK
        {
            get { return this._TongTienDaTraDVK; }
            set { this._TongTienDaTraDVK = value; }
        }

        private double _TongTienDVKThucNhan = 0;
        public double TongTienDVKThucNhan
        {
            get { return this._TongTienDVKThucNhan; }
            set { this._TongTienDVKThucNhan = value; }
        }
        #endregion Business Properties
        //==========================================================================

        #region Factory Methods
        public void SetIsNew()
        {
            MarkNew();
        }

        public void SetIsOld()
        {
            MarkOld();
        }

        public void SetIsDirty()
        {
            MarkDirty();
        }

        public object GetValue(string fieldName)
        {
            PropertyInfo propInfo = this.GetType().GetProperty(fieldName);
            return propInfo.GetValue(this, null);
        }

        public void SetValue(string fieldName, object value)
        {
            PropertyInfo propInfo = this.GetType().GetProperty(fieldName);
            propInfo.SetValue(this, value, null);
            MarkDirty();
        }

        protected override object GetIdValue()
        {
            return -1;
        }

        private BDDoanhThuBO()
        {
        }

        public BDDoanhThuBO(FbDataReader dataReader)
        {
            MarkAsChild();
            Fetch(dataReader);
            MarkOld();
        }

        public BDDoanhThuBO(FbDataReader dataReader, bool isRoot)
        {
            if (!isRoot)
                MarkAsChild();
            Fetch(dataReader);
            MarkOld();
        }

        public static BDDoanhThuBO NewRootBDDoanhThuBO()
        {
            return DataPortal.Create<BDDoanhThuBO>(new RootCriteria());
        }

        internal static BDDoanhThuBO NewChildBDDoanhThuBO()
        {
            return DataPortal.Create<BDDoanhThuBO>(new ChildCriteria());
        }

        public static string GetIDBDDoanhThuBO()
        {
            return "LoaiTrangPhucID";
        }
        #endregion Factory Methods
        //==========================================================================

        #region Criteria
        [Serializable()]
        public class RootCriteria
        {
            public RootCriteria() { }
        }

        [Serializable()]
        public class ChildCriteria
        {
            public ChildCriteria() { }
        }
        #endregion Criteria
        //==========================================================================

        #region Create
        [RunLocal]
        private void DataPortal_Create(RootCriteria criteria)
        {
        }

        private void DataPortal_Create(ChildCriteria criteria)
        {
            MarkAsChild();
            ValidationRules.CheckRules();
        }

        #endregion Create
        //==========================================================================

        #region Fetch
        [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Fetch(RootCriteria criteria)
        {
            this.Execute_Fetch(criteria);
        }

        protected void DataPortal_Fetch(string where)
        {
            this.Execute_Fetch(where);
        }

        protected void Execute_Fetch(RootCriteria criteria)
        {
            this.This_Fetch(criteria);
        }

        protected void Execute_Fetch(string where)
        {
            this.This_Fetch(where);
        }

        private void This_Fetch(RootCriteria criteria)
        {

        }

        private void This_Fetch(string where)
        {

        }

        private void Fetch(FbDataReader dataReader)
        {
        }
        #endregion Fetch
        //==========================================================================

        #region Insert
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Insert()
        {
            this.Execute_Insert();
        }

        protected void Execute_Insert()
        {
            this.This_Insert();
        }

        private void This_Insert()
        {
        }
        #endregion Insert
        //==========================================================================

        #region Update
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
            this.Execute_Update();
        }

        protected void Execute_Update()
        {
            this.This_Update();
        }

        private void This_Update()
        {
        }
        #endregion Update
        //==========================================================================

        #region Delete
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_DeleteSelf()
        {
            DataPortal_Delete(new RootCriteria());
        }

        private void DataPortal_Delete(RootCriteria criteria)
        {
            this.Execute_Delete(criteria);
        }

        protected void Execute_Delete(RootCriteria criteria)
        {
        }
        #endregion Delete
        //==========================================================================

        #region Internal method
        internal void Insert()
        {
            if (!this.IsDirty) return;
            DataPortal_Insert();
            MarkOld();
        }

        internal void Update()
        {
            if (!this.IsDirty) return;
            DataPortal_Update();
            MarkOld();
        }

        internal void DeleteSelf()
        {
            if (!this.IsDirty) return;
            if (this.IsNew) return;
            DataPortal_Delete(new RootCriteria());
            MarkNew();
        }
        #endregion Internal method
        //==========================================================================
    }
}